package robotAi

import xhhx.network.C2sMsg

typealias ActionResult = Int

const val FAILED = 1
const val SUCCESS = 2
const val RUNNING = 3

typealias NodeType = Int

const val CONTAINER = 1
const val LEAF = 2


abstract class RobotAction<T>() {
    var parentAction: RobotAction<T>? = null
    var nodeIndex = 0

    abstract fun GetType(): NodeType

    abstract fun GetDescription(): String

    abstract fun Run(t: T): ActionResult

    abstract fun ReceiveMessage(msg: C2sMsg): ActionResult

    abstract fun Reset(): RobotAction<T>
}

//fun ShowExecPath(robotAction: RobotAction<>?){
//    if (robotAction?.GetType() != LEAF){
//        return
//    }
//
//    var curNode  = robotAction;
//    var execPath = curNode.GetDescription()
//    while (true){
//        curNode = robotAction?.parentAction
//        if (curNode!= null) {
//            execPath = "${curNode.GetDescription()}->$execPath"
//            continue
//        }
//        break
//    }
//}